local Lua__Finalattack = fk.CreateSkill {
    name = "Lua__Finalattack",
    tags = {Skill.Permanent}
}


Fk:loadTranslationTable{
  ["Lua__Finalattack"] = "Finalattack",
  [":Lua__Finalattack"] = "持恒技，共鸣技，当你造成伤害前，你可以随机获得9个造成伤害时的技能，造成伤害后失去这些技能。",
  ["#Lua__Finalattack-prompt"] = "Finalattack：你可随机获得9个造成伤害时的技能，造成伤害后失去这些技能。",
}




Lua__Finalattack:addEffect(fk.PreDamage, {
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(Lua__Finalattack.name)  and target == player and
        (player.general == "DIEND" or player.deputyGeneral == "DIEND")
    end,
    on_cost =function (self, event, target, player, data)
        return player.room:askToSkillInvoke(player, {skill_name = Lua__Finalattack.name,prompt = "#Lua__Finalattack-prompt"})
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room

        local skills = {}
        for _, general_name in pairs(room.general_pile) do
          local general = Fk.generals[general_name]
          for _, skill_name in ipairs(general:getSkillNameList()) do
            local skill = Fk.skills[skill_name]
            if not player:hasSkill(skill, true) and string.find(Fk:getDescription(skill_name, "zh_CN"), "造成伤害时") then
              table.insert(skills, skill.name)
            end
          end
        end
        if #skills > 0 then
            local num
            if player:getMark("@@final_diend") == 1 then
                num = 21
            else
                num = 9
            end
            local skill_to_add = table.random(skills, num)
            room:addTableMark(player, "guifu_skill_record", skill_to_add)
            room:handleAddLoseSkills(player, skill_to_add, nil, true, false)
            room.logic:getCurrentEvent():findParent(GameEvent.Damage):addCleaner(function()
                room:handleAddLoseSkills(player, "-" .. table.concat(skill_to_add, "|-"), nil)
            end)
        end
    end,
})




return Lua__Finalattack 